package com.hison.tandainbao.controller;

import com.hison.tandainbao.entiy.pojo.domain.TbLocalculture;
import com.hison.tandainbao.entiy.pojo.dto.LocalcultueDto;
import com.hison.tandainbao.response.ResponseResult;
import com.hison.tandainbao.service.TbLocalcultureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: LocalCultureController
 * @Descripiton: 本地文化信息 控制类
 * @Author: 小郑
 * @Date： 2024/3/22 21:39
 * @Version：1.8
 **/
@RestController
@RequestMapping("/culture")
@Api(value = "本地人文信息管理接口", tags = "本地人文信息管理接口")
public class LocalCultureController {

    @Autowired
    private TbLocalcultureService tbLocalcultureService;



//    ---------------------普通用户接口-------------------------------------------

    /**
     * 发布文化信息
     */
    @PostMapping("/localCulture/add")
    @ApiOperation(value = "添加本地文化信息接口", produces = "application/json", httpMethod = "POST")
    public ResponseResult  add(@RequestBody LocalcultueDto localcultueDto){
        return  tbLocalcultureService.add(localcultueDto);
    }

    /**
     * 浏览本地文化
     */
    @GetMapping("/localCulture/browse")
    @ApiOperation(value = "浏览本地文化信息接口",produces = "application/json",httpMethod = "GET")
    public ResponseResult getLocalCulture(){
        return tbLocalcultureService.getLocalCulture();
    }

    //用户查看自己发布的文化信息
    @GetMapping("/myculture")
    @ApiOperation(value = "查找用户自己发布的文化信息",produces = "application/json",httpMethod = "GET")
    public  ResponseResult getMyCulture(){
        return  tbLocalcultureService.getMyCulture();
    }

    /**
     * //用户查看自己保存的文化信息草稿
     *
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see ResponseResult
     * @since version
     */
    @GetMapping("/mysaveDraftCulture")
    @ApiOperation(value = "用户查看自己保存的文化信息草稿",produces = "application/json",httpMethod = "GET")
    public ResponseResult getMySaveDraftCulture(){
        return tbLocalcultureService.getMySaveDraftCulture();
    }

    /**
     * //将草稿发布
     *
     * @param cultureId 区域性 ID
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see Integer
     * @see ResponseResult
     * @since version
     */
    @PutMapping("/putCulture")
    @ApiOperation(value = "将保存的草稿发布",produces = "application/json", httpMethod = "PUT")
    public ResponseResult putCulture(@RequestParam("cultureId") Integer cultureId){
        return  tbLocalcultureService.putCulture(cultureId);
    }


    /**
     * //删除自己发布的文化信息
     *
     * @param cultureId 区域性 ID
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see Integer
     * @see ResponseResult
     * @since version
     */
    @DeleteMapping("/localCultureDelete/{cultureId}")
    @ApiOperation(value = "删除自己发布的文化信息接口",produces = "application/json",httpMethod ="DELETE")
    public ResponseResult  delete(@PathVariable Integer cultureId){
        return tbLocalcultureService.delete(cultureId);

    }

    /**
     * //将文化信息保存为草稿
     *
     * @param tbLocalculture 结核病本地文化
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see TbLocalculture
     * @see ResponseResult
     * @since version
     */
    @PostMapping("/localCulture/saveDraftCulture")
    @ApiOperation(value = "将文化信息保存为草稿")
    public ResponseResult  saveDraftCulture(@RequestBody TbLocalculture tbLocalculture){
        return tbLocalcultureService.saveDraftCulture(tbLocalculture);
    }


    /**
     * 更新区域性信息    调用查询信息接口对信息回显
     *
     * @param tbLocalculture 结核病本地文化
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see TbLocalculture
     * @see ResponseResult
     * @since version
     */
    @PutMapping("/updateCultureInfo")
    @ApiOperation(value ="修改文化信息接口",produces = "application/json",httpMethod = "PUT")
    public ResponseResult  updateCultureInfo(@RequestBody TbLocalculture tbLocalculture){
        return  tbLocalcultureService.updateCultureInfo(tbLocalculture);
    }


    /**
     * 根据用户名查找对应用户发布的信息
     *
     * @param userName 用户名
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see String
     * @see ResponseResult
     * @since version
     */
    @GetMapping("/getCultureInfoByUserName")
    @ApiOperation(value = "根据用户名查找对应用户发布的信息",produces = "application/json",httpMethod = "GET")
    public  ResponseResult getCultureInfoByUserName(@RequestParam("userName") String userName){
        return  tbLocalcultureService.getCultureInfoByUserName(userName);
    }


    //-------------------------- 管理员方法 --------------------------------------
    /**
     * 审核本地文化当地文化
     *
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/28
     * @see ResponseResult
     * @since version
     */
    @PutMapping("/checkLocalCulture")
    @ApiOperation(value = "管理员审核本地文化接口",produces = "application/json",httpMethod = "PUT")
    public ResponseResult  checkLocalCulture(@RequestParam("cultureId") int cultureId, @RequestParam("status") String status){
        return tbLocalcultureService.checkLocalCulture(cultureId, status);
    }


    @GetMapping("/GetAll")
    @ApiOperation(value = "管理员查看本地所有文化信息接口",produces = "application/json",httpMethod = "GET")
    public  ResponseResult  getAllCultures( @RequestParam(value = "current", defaultValue = "1") Integer current, @RequestParam(value = "total",defaultValue = "10") Integer total){
        return  tbLocalcultureService.getAllCultures(current,total);
    }

    //管理员删除文化信息
    @DeleteMapping("delCulturesByAdmin")
    @ApiOperation(value = "管理员删除文化信息",produces = "application/json",httpMethod = "DELETE")
    public ResponseResult deleteCulturesByAdmin(@RequestParam("culturesId") Integer culturesId ){
        return  tbLocalcultureService.deleteCulturesByAdmin(culturesId);
    }

}